with open("wx.txt", "r", encoding='UTF-8') as f:
    content = f.read()  # 默认把文件中的所有数据读取出来,很可能会出现内存峰值
    print(content)

print('--------------------')

"""第二种:读取方式"""
with open("wx.txt", "r", encoding='UTF-8') as f:
    content = f.read(1)  # 读取指定的字符
    print(content)

print('--------------------')
"""第三种:"""
with open("wx.txt", "r", encoding='UTF-8') as f:
    content = f.readlines()  # 全部读取,每一行的内容为一个元素,返回的是列表
    print(content)

print('--------------------')
with open("wx.txt", "r", encoding='UTF-8') as f:
    while True:
        content = f.readline()  # 一次只读取一行
        if len(content) == 0:
            break
        print(content, end="")

print()
print('--------------------')
with open("wx.txt", "r", encoding='UTF-8') as f:
    content = f.readline(3)  # 一次只读取一行
    print(content)
